<template>
	<view class="programmeDetail">
		<view class="swiperBox">
			<swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000" style="height: 100%;">
				<!-- 存在视频 -->
				<swiper-item @click="amplification(item)" v-for="(item,i) in imgs" :key='i'>
					<image :src="item" mode=""></image>
				</swiper-item>
				<swiper-item v-for="(v,i) in videos" :key='i'>
					<video :src="v" autoplay="true"></video>
				</swiper-item>
			</swiper>
		</view>
		<view class="content">
			<view class="title line2">
				{{data.title}}
			</view>
			<view class="describe">
				{{data.desc}}
			</view>
			<view class="priceBox disFlex">
				<view>
					<text class="price">{{data.deposit}}</text>
					<text class="word">签约定金</text>
				</view>
				<view>
					<text class="price">{{data.cost}}</text>
					<text class="word" style="color: #ccc;">非会员价</text>
				</view>
			</view>
			<view  class="priceBox" style="margin-top: -5rpx;text-align: right;">
				<text style="font-size: 28rpx;" class="price">{{data.member_price==null?data.cost:data.member_price}}</text>
				<text class="word" style="color: red;">会员价</text>
			</view>
			<view class="typelist">
				<view class="labels" v-for="(item,i) in type" :key='i'>
					<view>{{item}}</view>
				</view>
			</view>
		</view>
		<view class="box10">
			<view class="info" style="height: auto;padding: 20upx 40upx;">
				<view class="left">服务区域</view>
				<view class="" style="display: flex;flex: 1;flex-wrap: wrap;">
					<view class="right" style="margin-left: 0;width: 30%;padding-left: 10upx;" v-for="(item,i) in data.citys" :key='i'>{{item}}<text
						 class="icons" v-show="data.citys.length!=i+1">|</text></view>
				</view>
			</view>
		</view>
		<view class="box10">
			<view class="info">
				<view class="left industry">展览行业</view>
				<view class="labels" v-for="(item,i) in industry" :key='i'>
					<view>{{item}}</view>
				</view>
			</view>
		</view>
		<view class="box10">
			<view class="remark">
				<view class="title">图文详情方案介绍</view>
				<view class="list">
					<!-- <view class="icon"></view> -->
					<view class="listText" v-html="data.content">

					</view>
				</view>
			</view>
		</view>

		<view class="bottom">
			<!-- <view class="iconfont icon-dianhua"></view> -->
			<!-- <view class="iconfont icon-xingxing-kong"></view> -->
			<image class="icon_dh" src="../../../static/img/icon_dh.png" mode="" @tap="phone"></image>
			<image class="icon_sc" :src="data.collect==1?'../../../static/img/icon_sccg.png':'../../../static/img/icon_sc.png'"
			 mode="" @tap="save(id)"></image>
			<button @tap="toDeposit">缴纳定金签约方案</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				data: '',
				citydata: [],
				city: [],
				industry: [],
				type: [],
				id: '',
				imgs: [],
				videos: []
			}
		},
		onLoad(option) {
			this.id = option.id
			this.geitinfo(option.id)
		},
		methods: {
			amplification(e) {
				// 预览图片
				let urls=[]
				this.imgs.map((v,i)=>{
					if(v==e){
						urls.unshift(v)
					}else{
						urls.push(v)
					}
				})
				uni.previewImage({
					urls: urls,
					longPressActions: {
						itemList: ['发送给朋友', '保存图片', '收藏'],
						success: function(data) {
							console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
						},
						fail: function(err) {
							console.log(err.errMsg);
						}
					}
				});
			},
			toDeposit() {
				uni.setStorageSync('sproject_id', this.id);
				uni.setStorageSync('hallId', ''); //清空账号id
				uni.setStorageSync('hallName', '')
				this.userid = uni.getStorageSync('userinfo').id;
				console.log(this.userid)
				if (this.userid) {
					uni.navigateTo({
						url: '/pages/index/programme/buyInfo?id=' + this.id
					})
				} else {
					this.getnav(this.router(`login`))
					uni.showToast({
						title: '请登录后重新尝试',
						icon: 'none'
					})
				}


			},
			geitinfo(v) {
				this.http('/api/project/read', 'post', {
						id: v,
					}, )
					.then((res) => {
						this.data = res.data
						this.data.carousel.map((v) => {
							if (v.type == 'video') {
								this.videos.push(v.url)
							} else {
								this.imgs.push(v.url)
							}
						})
						console.log(this.data)
						this.getcity()
						this.getindustry()
						this.gettype()
					})
			},
			getcity() {
				this.http('/api/project/city', 'post', {}, )
					.then((res) => {
						this.citydata = res.data
						let arr = this.data.city_id.split(',')
						arr.shift()
						arr.pop()
						this.citydata.forEach((v) => {
							arr.forEach((s) => {
								if (s == v.id) {
									this.city.push(v.shortname)
								}
							})
						})
					})

			},
			getindustry() {
				this.http('/api/industry/index', 'post', {}, )
					.then((res) => {
						let industry = res.data
						console.log(industry)
						let arr = this.data.industry_id.split(',')
						arr.shift()
						arr.pop()
						console.log(arr)
						industry.forEach((v) => {
							arr.forEach((s) => {
								// console.log(s)
								if (s == v.id) {
									this.industry.push(v.name)
								}
							})
						})
					})
			},
			gettype() {
				this.http('/api/project/boothType', 'post', {}, )
					.then((res) => {
						console.log(res)
						res.data.forEach((v) => {
							if (v.id == this.data.booth_type) {
								this.type.push(v.name)
							}
						})
						if (this.data.open_type == 1) {
							this.type.push('一面开口')
						} else if (this.data.open_type == 2) {
							this.type.push('两面开口')
						} else if (this.data.open_type == 3) {
							this.type.push('三面开口')
						} else if (this.data.open_type == 4) {
							this.type.push('四面开口')
						}
						let a = this.data.acreage
						this.type.push(a + 'm²')
					})
			},
			save(id) {
				let token = uni.getStorageSync('userinfo').token
				let user_id = uni.getStorageSync('userinfo').id
				let data = {
					token: token,
					user_id: user_id,
					project_id: id
				}
				this.http('/api/collect/save', 'post', data).then(res => {
					console.log(res)
					if (this.data.collect == 1) {
						if (res.sta == 200) {
							uni.showToast({
								title: '已取消收藏',
								icon: 'none'
							})
							this.data.collect = 0
						}
					} else {
						if (res.sta == 200) {
							uni.showToast({
								title: '收藏成功',
								icon: 'none'
							})
							this.data.collect = 1
						} else if (res.code == 2002) {
							uni.showToast({
								title: '请先登录',
								icon: 'none'
							})
						}
					}
				})


			},
			phone() {
				uni.makePhoneCall({
					phoneNumber: this.data.service_phone
				});
			}
		}
	}
</script>

<style lang="less">
	.typelist {
		display: flex;

	}

	.industry {
		width: 130rpx !important;
	}

	.bottomimg {
		text-align: center;
	}



	.list {
		display: flex;
		padding-bottom: 40rpx;
	}

	.icon {
		width: 16px;
		height: 16px;
		border-radius: 50%;
		background-color: #FFCB4B;
		margin-right: 15rpx;
		margin-top: 10rpx;
	}

	.programmeDetail {
		padding-bottom: 100rpx;

		.swiperBox {
			height: 500rpx;

			image,
			video {
				width: 100%;
				height: 100%;
			}
		}

		.content {
			padding: 40rpx 40rpx 30rpx 40rpx;

			.title {
				font-size: 48rpx;
				font-weight: bold;
			}

			.describe {
				margin-top: 40rpx;
				color: rgba(190, 201, 215, 1);
			}

			.priceBox {
				margin-top: 50rpx;

				.price {
					color: #FE7203;
					font-size: 48rpx;

					&::before {
						font-size: 32rpx;
						padding-right: 5rpx;
					}
				}

				.word {
					font-size: 24rpx;
					color: rgba(190, 201, 215, 1);
					padding-left: 10rpx;
				}
			}

			.labels {
				display: flex;
				align-items: center;
				margin-top: 50rpx;

				>view {
					text-align: center;
					background: rgba(254, 114, 3, .1);
					// opacity:0.1;
					border-radius: 10rpx;
					color: rgba(254, 114, 3, 1);
					padding: 8rpx;
					margin-right: 18rpx;
					margin-bottom: 15rpx;
				}
			}
		}

		.info {
			height: 112rpx;
			display: flex;
			align-items: center;
			padding: 0 40rpx;

			.left {
				font-size: 32rpx;
				color: rgba(190, 201, 215, 1);
				width: 140rpx;

			}

			.citys {
				display: flex;
				align-items: center;
				flex-wrap: wrap;
				margin-left: 10rpx;
			}

			.right {
				margin-left: 30rpx;
				font-size: 32rpx;
				color: rgba(38, 38, 38, 1);

				.icons {
					height: 22rpx;
					line-height: 22rpx;
					margin-left: 14rpx;
					color: #ccc;
				}
			}

			.labels {
				display: flex;
				align-items: center;
				margin-left: 24rpx;
				white-space: nowrap;
				overflow: hidden;

				// text-overflow:ellipsis;
				>view {
					text-align: center;
					background: rgba(254, 114, 3, .1);
					// opacity:0.1;
					border-radius: 10rpx;
					color: rgba(254, 114, 3, 1);
					padding: 8rpx;
				}
			}
		}

		.remark {
			padding-bottom: 0;

			ul,
			li {
				margin: 0;
				padding: 0;
			}

			padding: 40rpx;

			.title {
				font-size: 36rpx;
				font-weight: bold;
				color: rgba(38, 38, 38, 1);
			}

			.list {
				padding: 0;

				.listText {
					// margin-left: -20rpx;
				}
			}
		}

		.bottom {
			position: fixed;
			bottom: 0;
			height: 90rpx;
			width: 100%;
			left: 0;
			bottom: 0;
			display: flex;
			align-items: center;
			background-color: #fff;

			image {
				width: 40rpx;
				height: 40rpx;
				margin-left: 40rpx;
			}

			button {
				flex: 1;
				margin-left: 40rpx;
				outline: none;
				border: 0;
				border-radius: 0;
				line-height: 90rpx;
				background-color: #2291FF !important;
				color: #fff;
				font-size: 32rpx;
			}
		}
	}
</style>
